<?
$this->headTitle('Log Viewer - Search');
$this->headLink()->appendStylesheet($this->baseUrl('styles/log.css'));
?>
<style type="text/css">
<!--
tr {
    height: auto;
}
-->
</style>
<div>
    <h1>Search Logs</h1>

    <? $this->form->setAction($this->simpleUrl('search', 'logs')); ?>
    <?= $this->form; ?>

    <? if (isset($this->paginator)) : ?>
    Results:
    <hr />
    <br />
    <div>
        <? foreach ($this->paginator as $item) : ?>
        <? list($year, $month, $day) = explode('-', $item->date); ?>
        <a href="<?= $this->url(array('channel' => substr($item->channel, 1),'year' => $year, 'month' => $month, 'day' => $day), 'logs.view.channel') ?>"><?= $item->date; ?> | <?= $item->channel; ?></a>
        <table id="log">
            <tr class="head">
                <th>Nick</th>
                <th>Message</th>
            </tr>
            <? foreach (explode("\n", $this->teaser($item->contents, 200)) as $line) : ?>
            <tr>
                <td colspan="2"><?= $this->escape($line); ?></td>
            </tr>
            <? endforeach; ?>
        </table>
        <br />
        <? endforeach; ?>

        <? if (count($this->paginator) <= 0) : ?>
        <p>
            No results found...
        </p>
        <? endif; ?>
    </div>

    <div align="center">
        <?= $this->paginationControl($this->paginator, 'Elastic', 'logs/search-paginator.phtml'); ?>
    </div>
    <? endif; ?>
</div>